package com.lbd99.data.lbd.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lbd99.data.lbd.service.TInvitationService;
import com.lbd99.data.lbd.service.TMessageService;
import com.lbd99.data.lbd.vo.TInvitation;
import com.lbd99.data.lbd.vo.TMessageTemp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("message")
public class TMessageController {

    @Autowired
    private TMessageService tMessageService;

    /**
     * 分页查询数据
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping(value = "/getAll")
    @ResponseBody
    public Map<String, Object> getAll(int page,int rows,HttpServletRequest request) {
        Map<String, Object> result = new HashMap<String, Object>();
        PageHelper.startPage(page, rows);
        Map<String,Object> map2=new HashMap<String,Object>();
//        map2.put("phone",request.getParameter("phone"));
        List<TMessageTemp> list = tMessageService.selectList(map2);
        PageInfo<TMessageTemp> pages = new PageInfo<TMessageTemp>(list);
        result.put("total", pages.getTotal());
        result.put("rows", pages.getList());
        return result;
    }

    //添加
    @RequestMapping(value = "/add")
    @ResponseBody
    public Map<String, Object> add(String title,String content) {
        return tMessageService.insert(title,content);
    }
    
    
    
}
